package com.woniuxy.pxxt.controller;

import com.woniuxy.pxxt.common.vo.test.TestVo;
import com.woniuxy.pxxt.common.result.Result;
import com.woniuxy.pxxt.common.vo.exam.ExamAnswerVo;

import com.woniuxy.pxxt.entity.Test;
import com.woniuxy.pxxt.service.TestService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 考试的题目(PxxtTest)表控制层
 *
 * @author makejava
 * @since 2022-03-07 16:33:15
 */
@Api(value = "考试的题目")
@RestController
@RequestMapping("/test")
public class TestController {

    @Autowired
    private TestService testService;

    @ApiOperation(value = "添加试题")
    @PostMapping("/addTest")
    public Result addTest( @RequestBody TestVo test ){
        return testService.addTest(test);}


    @ApiOperation(value = "查找试题")
    @PostMapping("/findTest/{currentPage}/{pageSize}")
    public Result findTest(@PathVariable("currentPage") Integer currentPage,@PathVariable("pageSize") Integer pageSize,@RequestBody Test test){
        return testService.findTest(currentPage, pageSize, test);
    }


    @ApiOperation("查询这个用户的这个培训的成绩 通过用户id 培训id")
    @GetMapping("/findTestScore/{userId}/{trainId}")
    public Result findTestScore(@PathVariable Integer userId,
                                @PathVariable Integer trainId){
        return  testService.findTestScore(userId,trainId);
    }

    @ApiOperation(value = "根据id删除试题")
    @DeleteMapping("/deleteById/{id}")
    public Result deleteById (@PathVariable("id") Integer id){
        return testService.deleteById(id);
    }

    @ApiOperation(value = "根据难度或者单选多选查询题库试题")
    @GetMapping("/findBothStatus")
    public Result findBothStatus(){return testService.findBothStatus();}

    @ApiOperation(value = "根据培训的id查出考试题目")
    @GetMapping("/findExam/{trainId}")
    public Result findExamByTrainId(@PathVariable Integer trainId){
        return testService.findExamByTrainId(trainId);
    }

    @ApiOperation(value = "答案提交")
    @PostMapping("/submitAnswer")
    public Result submitAnswer(@RequestBody ExamAnswerVo examAnswer){
        return testService.examMark(examAnswer);
    }
}

